package com.yida.gwj.api.service;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yida.common.core.constant.SecurityConstants;
import com.yida.common.core.constant.ServiceNameConstants;
import com.yida.common.core.domain.R;
import com.yida.gwj.api.domain.*;
import com.yida.gwj.api.factory.RemoteGwjConfigFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 20230209 公维金配置服务
 *
 * @author hmh
 */
@FeignClient(contextId = "remoteGwjConfigService", value = ServiceNameConstants.GWJ_CONFIG_SERVICE, fallbackFactory = RemoteGwjConfigFallbackFactory.class)
public interface RemoteGwjConfigService {

    /**
     * 根据业务标识ID查询业务标识
     *
     * @param bizFlagId 业务标识ID
     * @param source    /
     * @return /
     */
    @GetMapping("/bizFlag/inner/{bizFlagId}")
    R<GwjConfBusinessFlag> selectGwjConfBusinessFlagByBizFlagId(@PathVariable("bizFlagId") Integer bizFlagId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据步骤ID查询业务步骤配置信息
     *
     * @param stepId 步骤ID
     * @param source /
     * @return /
     */
    @GetMapping("/stepConfig/inner/codeList/{stepId}")
    R<List<String>> selectGwjConfStepConfigInfoCodeListByBizFlagId(@PathVariable("stepId") Long stepId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据业务标识查询步骤ID列表
     *
     * @param flagId 业务标识ID
     * @param source /
     * @return /
     */
    @GetMapping("/step/inner/stepIdList/{flagId}")
    R<List<GwjConfStep>> selectGwjConfStepListByFlagId(@PathVariable("flagId") Integer flagId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询下一个步骤
     *
     * @param flagId      业务标识ID
     * @param currentStep 当前步骤
     * @param source      /
     * @return /
     */
    @GetMapping("/step/inner/nextStep/{flagId}/{currentStep}")
    R<GwjConfStep> selectNextGwjConfStepByFlagId(@PathVariable("flagId") Integer flagId, @PathVariable("currentStep") Long currentStep, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询上一个步骤
     *
     * @param flagId      业务标识ID
     * @param currentStep 当前步骤
     * @param source      /
     * @return /
     */
    @GetMapping("/step/inner/previousStep/{flagId}/{currentStep}")
    R<GwjConfStep> selectPreviousGwjConfStepByFlagId(@PathVariable("flagId") Integer flagId, @PathVariable("currentStep") Long currentStep, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据标准类型ID、地区ID、楼栋类型查询计算标准值数据
     *
     * @param areaId          地区ID
     * @param buildTypeId     楼栋类型ID
     * @param calculateTypeId 类型标准ID
     * @param source          /
     * @return /
     */
    @GetMapping("/calculateData/inner/{calculateTypeId}/{areaId}/{buildTypeId}")
    R<GwjConfCalculateData> selectCalculateDataByCalculateTypeIdAndAreaIdAndBuildTypeId(@PathVariable("calculateTypeId") Long calculateTypeId, @PathVariable("areaId") Long areaId, @PathVariable("buildTypeId") Integer buildTypeId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据标准类型ID获取计算标准详细信息
     *
     * @param calculateTypeId 类型标准ID
     * @param source          /
     * @return /
     */
    @GetMapping(value = "/calculateType/inner/{calculateTypeId}")
    R<GwjConfCalculateType> selectGwjConfCalculateTypeByCalculateTypeId(@PathVariable("calculateTypeId") Long calculateTypeId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据字典标签查询字典项
     *
     * @param dictLabel 字典标签
     * @param source
     * @return
     */
    @GetMapping(value = "/dictData/inner/{dictLabel}")
    R<GwjConfDictData> getGwjConfDictDataByDictLabel(@PathVariable("dictLabel") String dictLabel, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取最后一个步骤
     *
     * @param flagId 标识id
     * @param source 源
     * @return {@link R}<{@link GwjConfStep}>
     */
    @GetMapping(value = "/step/inner/final/{flagId}")
    R<GwjConfStep> getFinalStep(@PathVariable("flagId") Integer flagId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取第一个步骤
     *
     * @param flagId 标识id
     * @param source 源
     * @return {@link R}<{@link GwjConfStep}>
     */
    @GetMapping(value = "/step/inner/first/{flagId}")
    R<GwjConfStep> getFirstStep(@PathVariable("flagId") Integer flagId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取全部业务标识信息
     *
     * @param source
     * @param confBusinessFlag
     * @return {@link R}<{@link GwjConfStep}>
     */
    @PostMapping(value = "/bizFlag/inner/selectConfBusinessFlagList")
    R<List<GwjConfBusinessFlag>> selectConfBusinessFlagList(@RequestBody GwjConfBusinessFlag confBusinessFlag, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取全部步骤信息
     *
     * @param confStep
     * @param source
     * @return {@link R}<{@link List}<{@link GwjConfBusinessFlag}>>
     */
    @PostMapping(value = "/step/inner/selectConfStepList")
    R<List<GwjConfStep>> selectConfStepList(@RequestBody GwjConfStep confStep, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取下一个业务编号
     *
     * @param areaId    区域id
     * @param bizFlagId 商业标志标识
     * @param source    源
     * @return {@link R}<{@link GwjBaseBusinessNum}>
     */
    @GetMapping(value = "/businessNum/inner/getNextNum")
    R<GwjBaseBusinessNum> getNextNum(@RequestParam(value = "areaId") Long areaId, @RequestParam(value = "bizFlagId") Integer bizFlagId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取当前步骤信息
     *
     * @param stepId 一步id
     * @param source 源
     * @return {@link R}<{@link GwjConfStep}>
     */
    @GetMapping(value = "/step/selectByConfStepId")
    R<GwjConfStep> selectByConfStepId(@RequestParam(value = "stepId") Long stepId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 修改附件状态为不可上传
     *
     * @param serverIdentification
     * @param outServerIdentification
     * @param source
     * @return {@link R}<{@link Integer}>
     */
    @PutMapping(value = "/attachStatus/inner/ban")
    R<Integer> banUp(@RequestParam("serverIdentification") String serverIdentification, @RequestParam("outServerIdentification") String outServerIdentification, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 修改附件状态为可上传
     *
     * @param serverIdentification    业务标识 即 业务id
     * @param outServerIdentification 外部业务标识 即 文件配置标识
     * @param source
     * @return
     */
    @PutMapping(value = "/attachStatus/inner/allow")
    R<Integer> allowUp(@RequestParam("serverIdentification") String serverIdentification, @RequestParam("outServerIdentification") String outServerIdentification, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据参数键名查询参数值
     *
     * @param configKey 参数键名
     * @return /
     */
    @GetMapping(value = "/config/inner/configKey/{configKey}")
    R<String> innerGetConfigKey(@PathVariable("configKey") String configKey, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据参数键名修改参数值
     *
     * @param configKey 参数键名
     * @return /
     */
    @PutMapping(value = "/config/inner/edit")
    R innerEditGwjConfig(@RequestParam("configKey") String configKey, @RequestParam("configValue") String configValue, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 检测当前是否最后一步
     *
     * @param flagId 业务id
     * @param stepId 步骤id
     * @return JSONObject={"finishStatus":"true/false","nextStep":GwjConfStep}
     */
    @GetMapping(value = "/step/checkNextStepFinish")
    public R<JSONObject> checkNextStepFinish(@RequestParam("flagId") Integer flagId, @RequestParam("stepId") Long stepId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取业务步骤配置列表
     *
     * @return
     */
    @GetMapping(value = "/step/configList/inner")
    public R<JSONArray> getGwjConfStepConfigListInner(@RequestParam("stepId") Long stepId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据业务标识ID查询业务标识
     *
     * @param bizFlagId 业务标识ID
     * @param source    /
     * @return /
     */
    @GetMapping("/bizFlag/inner/flag/{bizFlagId}")
    R<JSONObject> selectGwjConfBusinessFlagInfoByBizFlagId(@PathVariable("bizFlagId") Integer bizFlagId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
